﻿using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string[] shapes = { "rectangle", "square", "triangle" };
        List<IShape> shapeList = new List<IShape>();
        Random rand = new Random();

        for (int i = 0; i < 10; i++)
        {
            string shapeType = shapes[rand.Next(shapes.Length)];
            IShape shape = ShapeFactory.CreateShape(shapeType);
            if (shape.IsValid())
            {
                shapeList.Add(shape);
                Console.WriteLine($"Created a {shapeType} with area: {shape.Area}");
            }
            else
            {
                Console.WriteLine($"Failed to create a valid {shapeType}");
            }
        }

        double totalArea = 0;
        foreach (var shape in shapeList)
        {
            totalArea += shape.Area;
        }

        Console.WriteLine($"Total area of all shapes: {totalArea}");
    }
}